package com.baidu.location;

import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.util.Log;

final class g
  implements ServiceConnection
{
  public final void onServiceConnected(ComponentName paramComponentName, IBinder paramIBinder)
  {
    e.a(this.a, new Messenger(paramIBinder));
    if (e.a(this.a) == null)
    {
      ak.e();
      return;
    }
    e.a(this.a, true);
    Log.d("baidu_location_client", "baidu location connected ...");
    try
    {
      do
      {
        paramComponentName = Message.obtain(null, 11);
        paramComponentName.replyTo = e.b(this.a);
        paramComponentName.setData(e.c(this.a));
        e.a(this.a).send(paramComponentName);
        e.a(this.a, true);
        e.d(this.a);
        ak.e();
      }
      while (e.e(this.a) == null);
      e.f(this.a).obtainMessage(4).sendToTarget();
      return;
    }
    catch (java.lang.Exception paramComponentName)
    {
    }
  }

  public final void onServiceDisconnected(ComponentName paramComponentName)
  {
    e.a(this.a, null);
    e.a(this.a, false);
    ak.e();
  }
}